package net.entelijan.cobean.util;

import javax.swing.UIManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public enum LookAndFeel {

	PLASTIC_XP("com.jgoodies.looks.plastic.PlasticXPLookAndFeel"), PLASTIC(
			"com.jgoodies.looks.plastic.PlasticLookAndFeel"), PLASTIC_3D(
			"com.jgoodies.looks.plastic.Plastic3DLookAndFeel"), WINDOWS(
			"com.jgoodies.looks.windows.WindowsLookAndFeel"), WINDOWS_CLASSIC(
			"com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"), MOTIV(
			"com.sun.java.swing.plaf.motif.MotifLookAndFeel"), NAPKIN(
			"net.sourceforge.napkinlaf.NapkinLookAndFeel"), METAL(
			"javax.swing.plaf.metal.MetalLookAndFeel"), NIMBUS(
			"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"), KUNSTSTOFF(
			"com.incors.plaf.kunststoff.KunststoffLookAndFeel");

	private String className;
	private static Log log = LogFactory.getLog(LookAndFeel.class);

	LookAndFeel(String className) {
		this.className = className;
	}

	public void use() {
		String lfName = this.className;
		try {
			UIManager.setLookAndFeel(lfName);
		} catch (Exception e) {
			log.warn("Could not load look and feel '" + lfName + "'. "
					+ e.getMessage());
		}

	}

	public void use(LookAndFeel secondChoise) {
		String lfName = this.className;
		try {
			UIManager.setLookAndFeel(lfName);
		} catch (Exception e) {
			log.warn("Could not load look and feel '" + lfName + "'. "
					+ e.getMessage());
			secondChoise.use();
		}

	}
}
